using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Exceptions;
using gdlmo.DNN.Modules.Article.Business;

namespace gdlmo.DNN.Modules.Article
{
	public abstract class ArticleUnSigned : PortalModuleBase
	{
		#region "Private Member"
		private int MaxChars
		{
			get 
			{
				object o = ViewState["MaxChars"];
				if (o == null) 
				{
					return 10;
				}
				return (int)o;
			}

			set 
			{				
				ViewState["MaxChars"] = value;
			}
		}
		#endregion

		#region "Customer Code"
		protected int GetMaxChars()
		{
			return MaxChars;
		}
		#endregion
		protected System.Web.UI.WebControls.DataGrid dgArticles;	
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{			
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

//		public string myEditURL(string KeyName, string KeyValue, string ControlKey)
//		{
//			string ctlKey = ControlKey;
//			if (string.Compare(ctlKey, "", false) == 0)
//			{
//				ctlKey = "Edit";
//			}
//			if ((string.Compare(KeyName, "", false) != 0) & (string.Compare(KeyValue, "", false) != 0))
//			{
//				//return Globals.NavigateURL(this.TabId, text2, new string[] { "mid=" + this.ModuleId.ToString(), KeyName + "=" + KeyValue });
//				//return Globals.NavigateURL(this.TabId,ControlKey,
//				return EditUrl(KeyName,KeyValue,ctlKey);
//
//			}
//			//return Globals.NavigateURL(this.TabId, text2, new string[] { "mid=" + this.ModuleId.ToString() });
//			return EditUrl(KeyName,KeyValue,ctlKey);
//			//			return "http://localhost/dotnetnuke/";
//		}
		#region Event Handlers

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				if (Settings["MaxChars"]!=null)
				{
					MaxChars = Int32.Parse(Settings["MaxChars"].ToString());
				}	
				try 
				{
					ArticleController objCtlArticle = new ArticleController();
					dgArticles.DataSource = objCtlArticle.GetArticleUnSigned(UserId);
					dgArticles.DataBind();
				}
				catch (Exception exc) 
				{
					Exceptions.ProcessModuleLoadException(this, exc);
				}
			}
		}
		#endregion		
	}
}